Friday, April 28, 2006

Programmers do the dumbest things

Ever do something really stupid in your code? I bet you can't say "No" with a straight face. But, don't you get irritated when you encounter someone else's blunders. I have found some real dillys lately and thought I might run them by anyone that ever reads my blog, which at this point is not a lot of people.

It seems that a lot of self-named .NET developers totally don't understand Exception Handling! For example, explain the need for the following Try Catch block, if you can.

private void DoNothing()
{
   try
   {
      // do some code
   }
   catch(Exception ex)
   {
      throw(ex);
   }
}

Did it never occur to the writer of this code that if they had not coded the try catch, that the results of a failure in the DoNothing method will be exactly the same. The try catch as coded basically is an unhandled exception, which could have been raised without the try catch.

Here's one more that completely baffled me when I came upon it recently.

Try
   IO.File.Move(oldPath, newPath)
Catch (ex As Exception)
   IO.File.Move(oldPath, newPath)
End Try

Go Figure! What is this? "If at first you don't succeed, Try, Try again?"

Take a minute and comment with something really dumb that you have done or seen.

Infamous Last Words

Programmers are infamous for trying to pass the buck when there appears to be a problem with their program and they are facing their accuser who is pointing the finger at them. For many years I have been amused at the new answers that the “innocent” developer comes up with before finally having to admit that they blew it. A short list is compiled below.

“Sounds like a hardware problem to me…”

“I only changed one line and it wasn’t in that area of the program…”

“It runs on my machine…”

“I tested it once and it ran ok. If it runs once, it will run every time, right?”

“I only made a change to the database; it would not cause a problem in the program…”

“The program has been running for 5 months and I never had a problem, I don’t think it’s the program…”


"Why would you ask if the change had been through QA?"

This one really backfires when you tell the user, who is a customer, “It sounds like an ID10T Error.” I personally don’t recommend that one be used at all.

Should you have some that you have heard, please comment on this blog.